<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>后台管理系统</title>
	    <meta name="author" content="BaiYY"/>
	    <meta charset="utf-8">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	    <meta name="renderer" content="webkit">
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/bootstrap.min.css"/>
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/Font/css/font-awesome.min.css"/>
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/index.css"/>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap.min.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/index.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.validate.min.js"></script>
	</head>

	<body>
		<div class="container">
			<div class="row">
				<div class="col-md-4 col-md-offset-4">
					<div class="panel panel-default input_login">
						<div class="panel-heading">
							<h3 class="panel-title text-center" style="font-size: 20px;font-weight: bold;">欢迎登录后台系统</h3>
						</div>
						<div class="panel-body">
							<form role="form" id="signupForm">
	                            <fieldset>
	                                <div class="form-group">
	                                    <input class="form-control" placeholder="请输入电话号码或者UID" name="telId" id="telId" type="text" autofocus="autofocus"/>
	                                </div>
	                                <div class="form-group">
	                                    <input class="form-control" placeholder="请输入密码" name="password" id="password" type="password"/>
	                                </div>
									<!--<div class="form-group">-->
										<!--<input class="form-control" placeholder="请输入验证码" name="yzm" id="yzm" type="text" size="15"/>-->
										<!--<p><img src="{:U('Admin/Login/yzm')}" alt="" width="200" height="30"></p>-->
									<!--</div>-->
	                                <input type="submit" class="btn btn-lg btn-block" value="登录" />
	                            </fieldset>
	                            
                       		 </form>
                       		 <br /><br />
                       		 <div class="col-md-12 text-center">
								<hr />
								<p><a href="regPage.html" style="font-weight:bold;color: #222;font-size: 20px;margin-right:5px ;">注册</a>成为代理</p>
								<!--<p><a href="">忘记密码，联系管理员重置密码</a></p>-->
							 </div>
						</div>
					</div>

				</div>
			</div>
		</div>
		<script type="text/javascript">
			$.validator.setDefaults({
				submitHandler:function() {
					var telId = $("#telId").val();
					var password = $("#password").val();
					var time = Date.parse(new Date())/1000;
					var url = "{:U('Admin/Login/loginCheck','','')}";
					$.ajax({
						type: "post",
						url: url,
						dataType: "json",
						data: {"telId":telId,"password":password,"time":time},
						success: function(data) {
							if(data == 'success') {
								window.location.href = "{:U('Admin/Main/index')}";
							} else if(data == 'unactive') {
								alert("该账号未通过审核，请联系管理员");
								return false;
							} else if(data == 'notExist') {
								alert("该账号不存在");
								window.location.href="{:U('Admin/Login/login')}";
								return false;
							} else if(data == 'passwordIncorrect') {
								alert("密码错误,请重新输入！");
								window.location.href="{:U('Admin/Login/login')}"
								return false;
							} else if(data == "danger"){
								alert("你的账户已过期！请联系管理员");
								window.location.href="{:U('Admin/Login/login')}"
								return false;
							} else if(data == "titles"){
								alert("你的账号已被封！请联系管理员");
								window.location.href="{:U('Admin/Login/login')}"
								return false;
							}else {
								console.log(data);
								alert('账号或密码错误！');
							}
						}
					});
				}
			});
			
			$().ready(function(){
				$("#signupForm").validate({
					rules: {
				      telId: "required",
				      password:"required",
				      telId: {
				        required: true,
				        minlength:6,
				        maxlength:11
				      },
				      password: {
				        required: true,
				        minlength: 6,
				        maxlength:20
				      } 
				  },
				  messages: {
				  	telId: "请输入您的账号",
				  	password: "请输入您的密码",
				  	telId: {
				  		required: "请输入电话号码或UID",
				  		minlength: "UID最少6位",
				  		maxlength: "电话号码最多11位"
				  	},
				  	password: {
				  		required: "请输入密码",
				  		minlength: "密码最少是6位",
				  		maxlength: "密码最多20位"
				  	}
				  }
				});
			});
		</script>
	</body>
</html>